## directories
Lib      = ../../../trunk/src
Src      = src
Tmp      = $(HOME)/tmp
Dirs     = $(Src) $(Tmp)

## files
Vars     = $(Tmp)/vars.out
Profile  = $(Tmp)/profile.out
CookBook = $(Lib)/release/cookbook.awk

## vars
Q="\""

## awk suff
Code     = $(shell ls *.awk | sed 's/^/$(Src)\//g'; )
F        = -f $(subst .awk ,.awk -f ,$(Code))
Run      = pgawk --dump-variables=$(Vars) \
                 --profile=$(Profile) \
                 -f $(CookBook) $F 

## install
install : dirs $(Code)

dirs :
	@$(foreach d, $(Dirs), \
	   if [ ! -d "$d" ]; \
              then echo "making $d"; mkdir -p $d; fi; )

## compile
$(Src)/%.awk : %.awk
	@echo "#compiling $<" >&2
	@gawk -f $(Lib)/cooker/ready.awk $< > $@

## execute
run : 
	$(Run)

one :
	$(Run) --source 'BEGIN { $(One); exit; }'

## demos
eg1 : install
	@$(MAKE) one One="readData($Q file etc/tests/weather0.csv$Q)" 

eg2 : install
	@$(MAKE) one One="readData($Q file etc/tests/weather.csv$Q)" 

eg3 : install
	@$(MAKE) one One="readData($Q file etc/tests/waveform0.csv$Q)" 

eg4 : install
	@$(MAKE) one One="readData($Q file etc/tests/waveform.csv$Q)" 
